<%@ page language="java" pageEncoding="UTF-8"%>
<script type="text/javascript" charset="UTF-8">
	var centerTabs;
	function addTabFun(opts) {
		if (centerTabs.tabs('exists', opts.title)){
			$.messager.progress('close');
			centerTabs.tabs('select', opts.title)
			return false;
		}
		if(opts.type==2){
			centerTabs.tabs('add', {
				title : opts.title,
				iconCls : opts.iconCls,
				closable : true,
				href:opts.src
			});
		}else{
			var iframe = $('<iframe frameborder="0" style="border:0;width:100%;height:99.2%;" />');
			var options = $.extend({
				title : '',
				iconCls : opts.iconCls,
				content : iframe,
				closable : true,
				closed: true
			}, opts);
			centerTabs.tabs('add', options);
			iframe.attr("src",opts.src);
		}
		$.messager.progress('close');
	};
 
	$(function() {
		centerTabs = $('#centerTabs').tabs({
			border : false,
			fit : true
		});
		var src = ctx+'/report/rBase/reportInit.htm?reportID=1';
		centerTabs.tabs('add', {
			title : '首页',
			closable : false,
			closed: true,
			iconCls : '',
			href:src
			//cache:false,
		});
 
		 $(".tabs li").live('contextmenu',function(e){
		        var subtitle =$(this).text();
		        centerTabs.tabs('select',subtitle);
		        
		        //显示快捷菜单
		        $('#menu').menu('show', {
		            left: e.pageX,
		            top: e.pageY
		        });
		        
		        return false;
		  });
		 
		 //刷新
		    $("#m-refresh").click(function(){
		        var currTab = centerTabs.tabs('getSelected'); 
		        var href = centerTabs.tabs('getSelected').panel('options').href;
		        if(href){
		        	var index = centerTabs.tabs('getTabIndex', centerTabs.tabs('getSelected'));
		        	centerTabs.tabs('getTab', index).panel('refresh');
		        }else{
		        	var url = $(currTab.panel('options').content).attr('src');
		        	var iframe = $('<iframe frameborder="0" style="border:0;width:100%;height:99.2%;" />');
			        centerTabs.tabs('update', {
		    			tab: currTab,
		    			options:{
							content : iframe,
							title : currTab.panel('options').title
						} 
		    		});
			        iframe.attr("src",url);
		        }
		        
		    });
		    
		    //关闭所有
		    $("#m-closeall").click(function(){
		        $(".tabs li").each(function(i, n){
		        	if(i!=0){
			            var title = $(n).text();
			            centerTabs.tabs('close',title);   
		        	}
		        });
		    });
		    
		    //除当前之外关闭所有
		    $("#m-closeother").click(function(){
		        var currTab = centerTabs.tabs('getSelected');
		        currTitle = currTab.panel('options').title;    
		        
		        $(".tabs li").each(function(i, n){
		            var title = $(n).text();
		            
		            if(currTitle != title&&i!=0){
		                centerTabs.tabs('close',title);            
		            }
		        });
		    });
		    
		    //关闭当前
		    $("#m-close").click(function(){
		        var currTab = centerTabs.tabs('getSelected');
		    	var index = centerTabs.tabs('getTabIndex', currTab);
		    	if(index!=0){
		    		currTitle = currTab.panel('options').title;    
			        centerTabs.tabs('close', currTitle);
		    	}
		    });
 
	});
</script>
<div id="centerTabs"></div>
<div id="menu" class="easyui-menu" style="width:150px; ">
    <div id="m-refresh">刷新</div>
    <div class="menu-sep"></div>
    <div id="m-closeall">全部关闭</div>
    <div id="m-closeother">除此之外全部关闭</div>
    <div class="menu-sep"></div>
    <div id="m-close">关闭</div>
</div>